<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<jsp:include page = "../metadatos.jsp" flush = "True" />
<html>
    <head>
        <title>NUEVO PEDIDO</title>
    </head>
    <body>
        <div class="wrapper">
            <header class="header">
                <script language="JavaScript">
                    function habilita() {
                        document.pedido.diasCredito.disabled = false;
                    }
                    function deshabilita() {
                        document.pedido.diasCredito.disabled = true;
                        document.pedido.diasCredito.value = "";
                    }
                </script> 
            </header><!-- .header-->
            <main class="content">
                <form method="post" action="./TarrySystem?action=nuevoPedido&index=2" class="formee" name="pedido">
                    <fieldset>
                        <c:if test="${tarryPrincipal.nErrores>0}">
                            <div class="formee-msg-error">
                                <h3>Incidencias:</h3>
                                <ul>
                                    <c:forEach items="${tarryPrincipal.errores}" var="e">
                                        <li><c:out value="${e}"/></li>
                                        </c:forEach>
                                </ul>
                            </div> 
                        </c:if>
                        <legend>Nuevo</legend>
                        <input type="hidden" name="idUser" value="<c:out value="${tarryPrincipal.user.id}"/>"/>
                        <div class="grid-6-12">
                            <label>ID Pedido<em class="formee-req">*</em></label>
                            <input type="text" name="idPedido" onKeyup="this.value = ventero(this.value)" value="<c:out value="${tarryPrincipal.idPedido}"/>"/>
                        </div>
                        <div class="grid-6-12">
                            <label>ID Cliente<em class="formee-req">*</em></label>
                            <input type="text" name="idCliente" onKeyup="this.value = ventero(this.value)" value="<c:out value="${tarryPrincipal.idClienteApuntador}"/>" />
                        </div>
                        <!-- SE AGREGA EL CONTROL DE OPCION DE FACTURA PARA DETERMINAR SI SE AGREGA IEPS -->
                        <div class="grid-12-12">
                            <label>TIPO COMPROBANTE<em class="formee-req">*</em></label>
                            <select name="tipoComprobante">
                                <option value="0">SELECCIONE</option>
                                <option value="1">REMISION</option>
                                <option value="2">FACTURA</option>
                            </select>
                        </div>

                        <!-- BANDERA DE CREDITO --> <!-- BANDERA DE CREDITO --> <!-- BANDERA DE CREDITO --> <!-- BANDERA DE CREDITO -->
                        <div class="grid-6-12" >
                            <ul class="formee-list">
                                <label>Forma de Pago<em class="formee-req">*</em></label>
                                <ul class="formee-list">
                                    <li><input name="pagoBandera" checked="checked" type="radio" value ="0"onclick="deshabilita()"/><label>AL CONTADO</label></li>
                                    <li><input name="pagoBandera" type="radio" value ="1"onclick="habilita()"/><label>CREDITO</label></li>
                                </ul>
                            </ul>
                        </div>
                        <div class="grid-6-12">
                            <label>Numero de dias credito<em class="formee-req">*</em></label>
                            <input type="text" value="" name="diasCredito" onKeyup="this.value = ventero(this.value)"/>
                        </div>
                        <!-- BANDERA DE CREDITO --><!-- BANDERA DE CREDITO --><!-- BANDERA DE CREDITO --><!-- BANDERA DE CREDITO -->
                        <div class="grid-3-12">
                            <input type="submit" value="Guardar"/>
                        </div>
                    </fieldset>
                </form>
                <!-- -->
                <fieldset>
                    <form method="post"  class="formee" action="./Clientes?action=filtrarCliente">
                        <fieldset>
                            <legend>filtro</legend>
                            <div class="grid-4-12">
                                <label>NOMBRE CLIENTE<em class="formee-req">*</em></label>
                                <input type="text" name="nombreCliente" onKeyup="this.value = txt(this.value)">
                            </div>
                            <div class="grid-4-12">
                                <input type="submit" value="filtrar">
                            </div>
                        </fieldset>
                        <!-- -->
                    </form>
                    <legend>CLIENTES</legend>
                    <div class="grid-12-12">   
                        <table class="bordered">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>NOMBRE CLIENTE</th>
                                    <th>CIUDAD</th>
                                    <th>ESTADO</th>
                                    <th>TELEFONO</th>
                                    <th>DOMICILIO</th>
                                    <th>CODIGO POSTAL</th>
                                    <th>COLONIA</th>
                                    <th>RFC</th>
                                </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${tarryPrincipal.clientes}" var="c">
                                    <tr onclick="location.href = './Clientes?action=cargaCliente&idCliente=<c:out value="${c.id}"/>'">
                                        <td><c:out value="${c.id}"/></td>
                                        <td><c:out value="${c.nombreCliente}"/></td>
                                        <td><c:out value="${c.ciudad}"/></td>
                                        <td><c:out value="${c.estado}"/></td>
                                        <td><c:out value="${c.telefono}"/></td>
                                        <td><c:out value="${c.domicilio}"/></td>
                                        <td><c:out value="${c.codigoPostal}"/></td>
                                        <td><c:out value="${c.colonia}"/></td>
                                        <td><c:out value="${c.rfc}"/></td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table> 
                    </div>
                </fieldset>
                <!-- -->
            </main>
        </div>
    </body>
</html>
